home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 010 / subs.bas (.txt) < prev    next >
Encoding:
GW-BASIC  |  1984-06-13  |  8.6 KB  |  245 lines

  1. 100  DIM LW(6) , HI(6)
  2. 200  FAC =46500 : CTY$="Los Angeles" : SRB$="Chatsworth"
  3. 300  ' cty$ is the harbor city (you may alter this)
  4. 400  ' srb$ is a suburb of the harbor city.  These names are used in messages.
  5. 500  ' The users name influences how the game proceedes.  See the subroutine
  6. 600  ' which evaluates the name at about line 19800.
  7. 700  '
  8. 800  '
  9. 900  LW(1)=21:LW(2)=19 : LW(3)=15 : LW(4)=10 : LW(5)=6 : LW(6)=4
  10. 1000  'LW(1)=19:LW(2)=15 : LW(3)=12 : LW(4)= 9 : LW(5)=6 : LW(6)=4
  11. 1100  HI(1)=18:HI(2)=14 : HI(3)=11 : HI(4)= 7 : HI(5)=5 : HI(6)=3
  12. 1200  'HI(1)=16:HI(2)=13 : HI(3)=10 : HI(4)= 7 : HI(5)=5 : HI(6)=3
  13. 1300  LINE INPUT"What is your name? ";PNAME$
  14. 1400  IF LEN(PNAME$)=0 THEN GOTO 1300
  15. 1500   LET Z=RND : LET GMS=0 : LET TS=0
  16. 1600  C=ASC(MID$(PNAME$,1,1))
  17. 1700  IF C>96 AND C<123 THEN MID$(PNAME$,1,1)=CHR$(C-32)
  18. 1800  GOSUB 19800
  19. 1900  DIM LN$(80),SH(80)
  20. 2000  RANDOMIZE TIMER
  21. 2100  PRINT "do you want instructions "PNAME$ " (y or n)"; :INPUT Q$
  22. 2200  IF Q$="n" THEN 4200
  23. 2300  CLS : PRINT "You are in control of a":COLOR 0,7
  24. 2400  LOCATE 1,25:PRINT CTY$ : COLOR 7,0
  25. 2500  PRINT "coastal defense cannon battery.  You are trying to sink approching"
  26. 2600  PRINT "warships.  A hit within" : COLOR 0,7 :LOCATE 3,25 :PRINT RNG
  27. 2700  COLOR 7,0 : LOCATE 3,31 : PRINT "yards will do it."
  28. 2800  PRINT "For more range : elevate (toward 45 degrees)."
  29. 2900  PRINT "If you overshoot : change the elevation away from 45 degrees."
  30. 3000  PRINT "If you allow the ships to move they will advance toward your"
  31. 3100  PRINT "harbor.  If you allow one to dock, you lose.  The ships move as"
  32. 3200  PRINT "time passes, thus if you shoot faster, the targets move less."
  33. 3300  PRINT "Entries are in degrees example: 2.5 is two and one half degrees. "
  34. 3400  PRINT "Some of the ships are submarines.  They remain below the water most
  35. 3500  PRINT "of the time.  Part of the time you may see their periscope.  Watch"
  36. 3600  PRINT "for the subs.  When the subs are below water you will not see them.
  37. 3700  PRINT "When a ship is above water you will see 's'.  When more than one"
  38. 3800  PRINT "one ship is in one location you will see the number of ships in "
  39. 3900  PRINT "that spot.  Some of the ships may on occasion try to shoot at your"
  40. 4000  PRINT "missle with an anti-missle.  If they hit your missle, then it never"
  41. 4100  PRINT "hits the water, and the attacking ships are safe for that turn. "
  42. 4200  PRINT "OK, LET'S GET STARTED" : LET STP=0
  43. 4300  ' sp% is # of ships, rng is how close the shot must come to be a hit
  44. 4400  ' inc is how fast the speed of the ships increases
  45. 4500  ' stp is the first step in speed
  46. 4600  IF CLSS=1 THEN LET SP% = 6 : LET RNG=90
  47. 4700  IF CLSS=2 THEN LET SP% = 3 : LET RNG=100
  48. 4800  IF CLSS=3 THEN LET SP% = 3 : LET RNG=150
  49. 4900  PRINT "Do you want the target ship to move between shots?"
  50. 5000  PRINT "(y or n)" ; : INPUT Q$
  51. 5100  IF Q$ <> "y" AND Q$ <> "n" GOTO 4900
  52. 5200  IF Q$ ="n" AND CLSS <>1 THEN  STP=0 : GOTO 6300
  53. 5300  IF Q$ ="n" AND CLSS = 1 GOTO 5600
  54. 5400  ' q$ must =y if we fall through
  55. 5500  LET STP=90 : GOTO 6300
  56. 5600  CLS : PRINT "Now look " PNAME$ ", being a person of your"
  57. 5700  PRINT "stature and skill level, I can not allow you to take the easy"
  58. 5800  PRINT "way to play this game.  I will force the ships to move.  As a "
  59. 5900  PRINT "penalty for trying to play this game the easy way I will not"
  60. 6000  LET SP%=6 : LET INC=1.5 :LET RNG=80 : STP=90
  61. 6100  PRINT "score a hit for YOU unless you are within" :COLOR 0,7
  62. 6200  LOCATE 5,43 : PRINT RNG :COLOR 7,0 : LOCATE 5,46: PRINT " yards!"
  63. 6300  IF STP< 140 GOTO 6500
  64. 6400  LET SP%=SP% + 1 : STP=90
  65. 6500  LET STP=STP * 1.1
  66. 6600  PRINT "The maximum speed of the advancing ships is" STP/20 "knots."
  67. 6700  PRINT "distance to the ships are:"
  68. 6800  FOR I = 1 TO SP% : SH(I)=8000-5000*RND(1)
  69. 6900  PRINT "     " SH(I) " yards " : NEXT I
  70. 7000  FOR K=1 TO SP%-1
  71. 7100  FOR I=1 TO SP%-1
  72. 7200  IF SH(I) > SH(I+1) THEN SWAP SH(I),SH(I+1)
  73. 7300  NEXT I
  74. 7400  NEXT K
  75. 7500  LET H=0
  76. 7600  REM "h=hits , s=shots this game , ts=total shots, gms=games "
  77. 7700  LET S=0 : LTM=TIMER : STM=LTM
  78. 7800  PRINT " "  : PRINT "elevation" ;
  79. 7900  INPUT E
  80. 8000  CTM=TIMER : IVL=CTM - LTM : LTM=CTM
  81. 8100  LET S=S+1
  82. 8200  IF (E > 0.4 ) AND ( E < 88) THEN 10800
  83. 8300  IF (E < -2 ) OR (E > 92) THEN 9700
  84. 8400  IF E <> 90 THEN 8700
  85. 8500  PRINT "you shot STRAIGHT up...."
  86. 8600  GOTO 8800
  87. 8700  PRINT " you shot nearly straight up..."
  88. 8800  PRINT "Lets get out of here!" : JJ=40
  89. 8900  FOR I = 1 TO 10 : FOR J=1 TO 10 : JJ=JJ+1 : SOUND JJ,1 : NEXT J
  90. 9000  PRINT TAB(15) "." : NEXT I
  91. 9100  SOUND 40,40 : COLOR 0,7
  92. 9200  PRINT TAB(13) "boom!                                                               "
  93. 9300  COLOR 7,0
  94. 9400  PLAY "l10 o1abcdef l32 o1abcdefabcdef"
  95. 9500  PRINT
  96. 9600  GOTO 7800
  97. 9700  PRINT "The mayor of " CTY$ " should enjoy that one."
  98. 9800  PRINT "That round may hit " SRB$ "!"
  99. 9900  LET C=1
  100. 10000  GOTO 9500
  101. 10100  COLOR 0,7:PRINT TAB(3) "NEWS FLASH!" : COLOR 7,0
  102. 10200  PRINT SRB$ " house hit by MYSTERY MISSLE"
  103. 10300  PLAY "t60  o4aaaaaaaaaaaaa t120" : CLS
  104. 10400  LET C=0
  105. 10500  RETURN
  106. 10600  PRINT "ILLEGAL VALUE.  Try again."
  107. 10700  GOTO 9500
  108. 10800  CLS
  109. 10900  IF C <> 1 THEN 11100
  110. 11000  GOSUB 10100
  111. 11100  IF E < 0.5 THEN 10600
  112. 11200  LET E2=2*E/57.2958
  113. 11300  REM "j is where the shot landed"
  114. 11400  LET J =FAC    * SIN(E2)
  115. 11500  GOSUB 14000
  116. 11600  IF H < SP% GOTO 7800
  117. 11700  REM "if we fall through then we hit all the ships"
  118. 11800  LET TS=TS + S
  119. 11900  LET GMS=GMS + 1
  120. 12000  PLAY "l32 o6abcdef abcdef abcdef abcdef abcdef"
  121. 12100  IF S< 20 THEN 12300
  122. 12200  PRINT " ***** finally ******"
  123. 12300  TS%=TIMER - STM
  124. 12400  MN%=TS% / 60 : SC%= TS% MOD 60
  125. 12500  PRINT S "rounds fired in " MN% " minutes" SC% " seconds"
  126. 12600  IF TS / GMS < SP% * 3 THEN LET INC = INC * 1.2
  127. 12700  IF STP <>0 GOTO 13300
  128. 12800  IF GMS > 4 GOTO 13100
  129. 12900  IF TS / GMS > 9  GOTO 13300
  130. 13000  PRINT "You are TOO good."
  131. 13100  PRINT "I am going to allow the ship to move between shots."
  132. 13200  LET STP=100
  133. 13300  PRINT "Another game " PNAME$" (y or n)";
  134. 13400  INPUT Q$
  135. 13500  IF Q$ = "y" THEN 6300
  136. 13600  IF Q$ <> "n" THEN 13300
  137. 13700  PRINT "ending now"
  138. 13800  PRINT "You played"GMS" games, and you took an average of"TS/GMS" shots."
  139. 13900  SYSTEM
  140. 14000  REM "FILL IN THE STATUS LINE WITH ALL DOTS"
  141. 14100  LOCATE 13,1
  142. 14200  FOR K=1 TO 80 : LN$(K) ="." : NEXT K
  143. 14300  LET S%=(J / 100) : IF S% > 80 THEN LET S% = 81
  144. 14400  ' ln is the line on the screen that the shot is placed
  145. 14500  ' s% - w  is the column on the screen that the shot is placed
  146. 14600  W%=31 : LN%= 0 : SHT$="n"
  147. 14700  FOR X%=1 TO 4 : Z% = 5 - X%
  148. 14800   FOR Y%=1 TO 3 : W%= W% - Z% : LN%=LN%+ 1
  149. 14900    IF S% > W% THEN GOSUB 21300
  150. 15000   NEXT Y%
  151. 15100  NEXT X%
  152. 15200  LOCATE 13,1
  153. 15300  FOR I=1 TO SP%
  154. 15400   SB= I MOD 3
  155. 15500   IF SH(I) = 0 GOTO 17400
  156. 15600   TMF = (1 + ((IVL -8  ) / 8  ))
  157. 15700   LET MV= (STP * (2 * (RND(1) -1 ) ) )
  158. 15800   LET SH(I)=SH(I) + (MV + (MV * TMF)) / 2
  159. 15900   IF SH(I) > 100 GOTO 16500
  160. 16000  LOCATE 17,1
  161. 16100   PRINT "The enemy ship landed at your harbor.  You lose."
  162. 16200   LET I=SP%
  163. 16300   LET H=I
  164. 16400   GOTO 17400
  165. 16500   LET N=SH(I)-J
  166. 16600   LET D=INT(N)
  167. 16700   IF ABS(D) > RNG THEN 17400
  168. 16800  REM "if we branch then we missed ship(i) "
  169. 16900  REM "if we fall through, then we hit one "
  170. 17000   LOCATE 14+I,I : PRINT "GOT 'EM"
  171. 17100   LET SH(I)=0
  172. 17200   PLAY "l32 o2abcdef abcdef abcdef abcdef abcdef"
  173. 17300   LET H=H+1
  174. 17400   LET II% = SH(I)/100
  175. 17500  ' every 1 ST ship is a sub
  176. 17600   IF  SB <> 1 GOTO 18000
  177. 17700  ' show only the periscope once out of 4
  178. 17800   IF  S MOD 4 <>2  GOTO 18400
  179. 17900   IF LN$(II%)="." THEN LET LN$(II%)="|" : GOTO 18400
  180. 18000   IF LN$(II%)="3" THEN LET LN$(II%)="4"
  181. 18100   IF LN$(II%)="2" THEN LET LN$(II%)="3"
  182. 18200   IF LN$(II%)="s" THEN LET LN$(II%)="2"
  183. 18300   IF LN$(II%)="." THEN LET LN$(II%)="s"
  184. 18400  NEXT I
  185. 18500  LOCATE 13,1
  186. 18600  ' BYPASS IF SHOT HIT
  187. 18700  LET S%=J/100 : IF S% < 81 THEN 19000
  188. 18800  LET LN$(80)=">" : LET S%=80 : GOTO 19100
  189. 18900  IF J=0 THEN GOTO 19100
  190. 19000  LET LN$(S%)="*"
  191. 19100  FOR K=1 TO 80 : PRINT LN$(K) ; : NEXT K
  192. 19200  FOR I= 1 TO S% - 1
  193. 19300  IF SH(I) <> 0 THEN GOTO 19500
  194. 19400  SH(I) = SH(I+1) : SH (I+1)= 0
  195. 19500  NEXT I
  196. 19600  'put ships not hit to the front
  197. 19700  RETURN
  198. 19800  '*******  Evaluate the name ******
  199. 19900  '   class 1 users have it hard.
  200. 20000  '   class 3 users have it easy.
  201. 20100  '   everyone else is in the middle.
  202. 20200  '
  203. 20300  '  Before the evaluation is done the first character of the name was
  204. 20400  '  forced to be upper case.
  205. 20500  '  The first three characters of the name are used in the evaluation.
  206. 20600  LET F$=MID$(PNAME$,1,3)
  207. 20650  ' names begining with the following characters have it tough.
  208. 20700  IF (F$="Mar" ) OR (F$="Ger" ) OR (F$="Mr." ) THEN  RNG=90:CLSS=1:RETURN
  209. 20750  ' names begining with the following characters have it easy.
  210. 20800  IF (F$="Kat" ) OR (F$="Lee" ) THEN RNG=110:CLSS=3:RETURN
  211. 20900  ' class 2 player setup
  212. 21000  LET RNG=100: LET CLSS=2 :RETURN
  213. 21100  ' ANTI SHOT SUBROUTINE
  214. 21200  Q%= (J - SH(1) ) / 100
  215. 21300  LOCATE LN%,S%-W% : PRINT "." : SOUND 2000-(LN%*100),2
  216. 21400  IF LN% > 6 THEN GOTO 21900
  217. 21500  IF SHT$ = "y" THEN GOTO 21600
  218. 21600  Q%= (J - SH(1) ) / 100
  219. 21700  IF (Q% > LW(LN%) ) OR (Q% < HI(LN%) ) THEN GOTO 21900
  220. 21800  SHT$="y" : SHL%=13 : SHC%=(SH(1) / 100)
  221. 21900  IF SHT$="n" THEN GOTO 24200
  222. 22000  SHL%=SHL% - 1 : SHC%=SHC% + 1
  223. 22100  'LOCATE LN%+10,1
  224. 22200  'PRINT LN%  SHL%  SHC% S%-W% S% W%
  225. 22300  IF SHC% > 80 THEN GOTO 24200
  226. 22400  LOCATE SHL%,SHC% : PRINT "/"
  227. 22500  IF (SHL% <  LN%)                     GOTO 24200
  228. 22600  IF (SHC% +1<  S%-W%+Z%)AND (SHL%  =LN% ) THEN GOTO 22700 ELSE GOTO 24200
  229. 22700  ' else hit shot with anti shot
  230. 22800  LOCATE   SHL%,SHC%-2 : PRINT "   *    " : PLAY "l64 o6abcdef abcdef "
  231. 22900  LOCATE SHL%-1,SHC%-2 : PRINT "  ***   "
  232. 23000  LOCATE SHL%+1,SHC%-2 : PRINT "  ***   " : PLAY "l64 o6abcdef abcdef "
  233. 23100  COLOR 0,7
  234. 23200  LOCATE SHL%-1,SHC%-1 : PRINT  "     "
  235. 23300  LOCATE SHL%+1,SHC%-1 : PRINT  "     "
  236. 23400  LOCATE   SHL%,SHC%-2 : PRINT "       "  : PLAY "l64 o6abcdef abcdef "
  237. 23500  LOCATE SHL%-1,SHC%-2 : PRINT "*******"
  238. 23600  LOCATE   SHL%,SHC%-2 : PRINT "*******" : PLAY "l64 o6abcdef abcdef "
  239. 23700  LOCATE   SHL%,SHC%-2 : PRINT "       "
  240. 23800  LOCATE SHL%-1,SHC%-2 : PRINT "       "
  241. 23900  LOCATE SHL%+1,SHC%-2 : PRINT "       " : PLAY "l64 o6abcdef abcdef "
  242. 24000  X%=4 : Y%=3 :J=0
  243. 24100  COLOR 7,0
  244. 24200  RETURN
  245.